package org.bjf.demo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import java.io.IOException;
import java.lang.reflect.Type;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * fastJaon 使用serializeUsing制定属性的序列化类
 */
@Data
@Accessors(chain = true)
public class FastJsonSerialize {

  private Long id;

  @JSONField(serializeUsing = ImgSerializer.class)
  private String name;


  public static class ImgSerializer implements ObjectSerializer {


    @Override
    public void write(JSONSerializer serializer, Object value, Object fieldName, Type fieldType,
        int features) throws IOException {
      serializer.write("xxoo " + value);
    }
  }
}
